package com.example.sports_meet.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.sports_meet.R;
import com.example.sports_meet.entity.SelectM;

import java.util.ArrayList;
import java.util.List;

public class SelectAdapter extends BaseAdapter {
    private List<SelectM> pdata = new ArrayList<SelectM>();
    private Context context;

    public SelectAdapter(List<SelectM> pdata, Context context) {
        this.pdata = pdata;
        this.context = context;
    }

    public SelectAdapter() {
        super();
    }

    @Override
    public int getCount() {
        return pdata.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    static class ViewHolder {
        public TextView Tv_wr_areaname, Tv_wr_dc_man, Tv_wr_mt_man;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view == null) {
            holder = new ViewHolder();
            view = LayoutInflater.from(context).inflate(R.layout.listrepeat, viewGroup, false);
            holder.Tv_wr_areaname = (TextView) view.findViewById(R.id.tv_wr_areaname);
            holder.Tv_wr_dc_man = (TextView) view.findViewById(R.id.tv_wr_dc_man);
            holder.Tv_wr_mt_man = (TextView) view.findViewById(R.id.tv_wr_mt_man);
            view.setTag(holder);

        } else {
            holder = (ViewHolder) view.getTag();
        }
        holder.Tv_wr_areaname.setText(pdata.get(i).getNo());
        holder.Tv_wr_mt_man.setText(pdata.get(i).getName());
        holder.Tv_wr_dc_man.setText(pdata.get(i).getTime());


        return view;
    }
}

